/*
 * @Date: 2023-01-22 02:17:37
 * @LastEditors: 恶名扬 2080156129@qq.com
 * @LastEditTime: 2023-01-24 04:59:19
 * @FilePath: \campus-repair-platform\server\schema\reception\user.js
 */
/**
 * login_schema   登录验证
 * phone_schema   手机号验证
 * verify_code_schema       验证手机号和验证码
 * update_phone_schema      修改手机号验证
 * update_pwd_oldPwd_schema 修改密码验证
 */

const joi = require("joi")
const { phone: p, account, password } = require("../common")
const phone = p

const code = joi.string().length(4).error(new Error("验证码格式有误"))

exports.login_schema = {
  body: {
    account,
    password: password.required(),
  },
}

exports.phone_schema = {
  body: {
    phone: phone.required(),
    type: joi.number().min(1).max(3).required()
  },
}

exports.info_phone_schema = {
  body: {
    phone: phone.required(),
  },
}

exports.verify_code_schema = {
  body: {
    phone: phone.required(),
    code: code.required(),
  },
}

exports.update_phone_schema = {
  body: {
    phone: phone.required(),
    code: code.required(),
  },
}

exports.update_pwd_oldPwd_schema = {
  body: {
    oldPassword: password.required().error(new Error("旧密码格式有误")),
    newPassword: password.required().error(new Error("新密码格式有误")),
  },
}

exports.retrieve_schema = {
  body: {
    phone: phone.required(),
    code: code.required(),
    type: joi.number().min(1).max(3).required(),
    password: password.required().error(new Error("密码格式有误")),
  }
}
